package com.mbbb.yygh.oss.controller;

import com.mbbb.yygh.common.result.R;
import com.mbbb.yygh.oss.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(description="阿里云文件管理")
@RestController
@RequestMapping("/admin/oss/file")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    @ApiOperation(value = "文件上传")
    @PostMapping("upload")
    public R upload(MultipartFile file) {

        //获取文件上传的路径
        //https://hospital0918.oss-cn-beijing.aliyuncs.com/mm2.jpg
        String url = fileUploadService.uploadFile(file);
        return R.ok().data("url",url);
    }
}
